﻿Public Class FrmBase

    Dim ban As Boolean = True

    Protected Overridable Sub FrmBase_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        propTextBox()
        bnCancelar_Click(sender, e)
    End Sub


    Protected Overridable Sub bnGuardar_Click(sender As System.Object, e As System.EventArgs) Handles btGuardar.Click
        For Each ctr As Control In Me.pBase.Controls
            If Not TypeOf ctr Is Label Then
                ctr.Enabled = False
            End If
        Next
    End Sub

    Protected Overridable Sub bnNuevo_Click(sender As System.Object, e As System.EventArgs) Handles btNuevo.Click
        For Each ctr As Control In Me.pBase.Controls
            If Not TypeOf ctr Is Label Then
                ctr.Enabled = True
                ctr.Text = ""
                If ban And TypeOf ctr Is TextBox Then
                    ctr.Focus()
                    ban = False
                End If
            End If
        Next
    End Sub

    Protected Overridable Sub bnEditar_Click(sender As System.Object, e As System.EventArgs) Handles btEditar.Click
        For Each ctr As Control In Me.pBase.Controls
            If Not TypeOf ctr Is Label Then
                ctr.Enabled = True
            End If
        Next
    End Sub

    Private Sub bnSalir_Click(sender As System.Object, e As System.EventArgs) Handles btSalir.Click
        Me.Close()
    End Sub

    Protected Overridable Sub bnCancelar_Click(sender As System.Object, e As System.EventArgs) Handles btCancelar.Click
        For Each ctr As Control In Me.pBase.Controls
            If Not TypeOf ctr Is Label Then
                ctr.Enabled = False
                ctr.Text = ""
            End If
        Next
    End Sub

    Protected Overridable Sub bnEliminar_Click(sender As System.Object, e As System.EventArgs) Handles btEliminar.Click
        For Each ctr As Control In Me.pBase.Controls
            If Not TypeOf ctr Is Label Then
                ctr.Enabled = False
                ctr.Text = ""
            End If
        Next
    End Sub

    Protected Sub msnBoxInformacion(mensaje As String)
        MessageBox.Show(mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Protected Sub msnBoxExcla(mensaje As String)
        MessageBox.Show(mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    End Sub

    Protected Sub msnBoxWarning(mensaje As String)
        MessageBox.Show(mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    End Sub

    Private Sub propTextBox()
        Dim tb As TextBox
        For Each ctr As Control In Me.pBase.Controls
            If TypeOf ctr Is TextBox Then
                tb = DirectCast(ctr, TextBox)
                tb.BorderStyle = BorderStyle.FixedSingle
            End If
        Next
    End Sub

End Class